﻿#pragma once
#include<iostream>
#include<sys/shm.h>
#include<sys/msg.h>
#include<sys/sem.h>
#include"tool/ThreadPool.h"
#include"task/TaskFactory.h"
#include"tool/ConnectionPool.h"
using namespace std;

class SharedMemory
{
public:
	SharedMemory();
	~SharedMemory();
	void ReadMemory();//ȡڴ

private:
	int shmid;
	void* shmaddr;
	int msgidA;
	int msgidB;
	ThreadPool* threadPool;//̳߳
	ConnectionPool* connPool;//ӳ
	// 信号量ID
	int sem_shm;    // 用于共享内存访问控制

	int sem_p(int semid, int semindex);  // P操作
	int sem_v(int semid, int semindex);  // V操作
};
